<template>
    <a-spin :spinning="confirmLoading">
        <j-form-container :disabled="formDisabled">
            <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
                <a-row>

                    <a-col :span="6">
                        <a-form-model-item label="服务类型" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="serverType">
                            <a-input v-model="model.serverType" placeholder="请输入中间库服务类型" disabled></a-input>
                        </a-form-model-item>
                    </a-col>
                    <a-col :span="6">
                        <a-form-model-item label="服务名" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="serverCode">
                            <a-input v-model="model.serverCode" placeholder="请输入中间库服务名" disabled></a-input>
                        </a-form-model-item>
                    </a-col>

                    <a-col :span="6">
                        <a-form-model-item label="任务名" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="taskCode">
                            <a-input v-model="model.taskCode" placeholder="请输入中间库任务名" disabled></a-input>
                        </a-form-model-item>
                    </a-col>
                    <a-col :span="6">
                        <a-form-model-item label="任务描述" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="taskCode">
                            <a-input v-model="model.taskDesc" placeholder="请输入中间库任务描述" disabled></a-input>
                        </a-form-model-item>
                    </a-col>
                </a-row>
                <a-row>
                    <a-col :span="6">
                        <a-form-model-item label="外围系统接类型" :labelCol="labelCol" :wrapperCol="wrapperCol"
                                           prop="interfaceCode">
                            <a-input v-model="model.exoServerType" placeholder="请输入外围系统接类型" disabled></a-input>
                        </a-form-model-item>
                    </a-col>
                    <a-col :span="6">
                        <a-form-model-item label="外围系统接口号" :labelCol="labelCol" :wrapperCol="wrapperCol"
                                           prop="exoServerCode">
                            <a-input v-model="model.exoServerCode" placeholder="请输入外围系统接口号" disabled></a-input>
                        </a-form-model-item>
                    </a-col>
                    <a-col :span="6">
                        <a-form-model-item label="外围系统接口描述" :labelCol="labelCol" :wrapperCol="wrapperCol"
                                           prop="exoServerDesc">
                            <a-input v-model="model.exoServerDesc" placeholder="请输入外围系统接口描述" disabled></a-input>
                        </a-form-model-item>
                    </a-col>

                </a-row>
                <a-row>
                    <a-col :span="24">
                        <a-form-model-item label="测试数据" :labelCol="labelCol2" :wrapperCol="wrapperCol2" prop="testData">
                            <a-textarea v-model="model.testData" placeholder="测试数据" :rows="20" disabled/>
                        </a-form-model-item>
                    </a-col>
                </a-row>
            </a-form-model>
        </j-form-container>
    </a-spin>
</template>

<script>

    import { postAction } from '../../../api/manage'

    export default {
        name: 'MsiTaskExoServerTestForm',
        components: {},
        props: {
            //表单禁用
            disabled: {
                type: Boolean,
                default: false,
                required: false
            }
        },
        data() {
            return {
                model: {},
                labelCol: {
                    xs: { span: 24 },
                    sm: { span: 8 },
                },
                wrapperCol: {
                    xs: { span: 24 },
                    sm: { span: 14 },
                },
                labelCol2: {
                    xs: { span: 24 },
                    sm: { span: 2 },
                },
                wrapperCol2: {
                    xs: { span: 24 },
                    sm: { span: 21 },
                },

                confirmLoading: false,
                validatorRules: {},
                url: {
                    wsTest: '/msiws/MsiServerTest/testWebService',
                    restTest: '/msiws/MsiServerTest/testRestFull',
                }
            }
        },
        computed: {
            formDisabled() {
                return this.disabled
            },
        },
        created() {
        },
        methods: {
            edit(record) {
                this.model = Object.assign({}, record)
                this.visible = true
            },
            test() {
                let param = {}
                let url = this.url.wsTest
                param = Object.assign({}, {
                    serverCode: this.model.serverCode,
                    taskCode: this.model.taskCode,
                    testData: this.model.testData
                })
                if ('REST' == this.model.serverType) {
                    url = this.url.restTest
                    //param = {}
                }
                postAction(url, param).then((res) => {
                    this.$message.success(res.message)

                })

            }
        }
    }
</script>
